package net.csdn.business.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import net.csdn.business.common.constant.CommonConstants;

/**
 * @author likun
 * @date 2022/6/9 15:51
 */
public interface UserLikeEnum {
    /**
     * 操作默认值（重复点赞，相当于取消）
     */
    Integer ACTION_DEFAULT_VALUE = CommonConstants.INT_ZERO;

    @Getter
    @AllArgsConstructor
    enum ActionEnum {
        /**
         * 操作
         */
        DIGG(1, "点赞", ResourceEnum.KeyEnum.DIGG_COUNT),
        NO_DIGG(2, "点踩", ResourceEnum.KeyEnum.NO_DIGG_COUNT),
        ;
        final int code;

        final String desc;

        final ResourceEnum.KeyEnum keyEnum;

        public static ActionEnum ofCode(int code) {
            for (ActionEnum action : ActionEnum.values()) {
                if (action.code == code) {
                    return action;
                }
            }
            throw new IllegalArgumentException("UserLikeEnum#ActionEnum param error");
        }
    }
}
